package com.gupao.factory.abstr;

import com.gupao.factory.computer.Computer;

/**
 *
 * Created by ktyan on 2017/5/21.
 */
public abstract class AbstractFactory
{
    /**
     *
     * @return
     */
    protected abstract Computer getComputer();
    
    /**
     * 根据名称获取品牌电脑
     *
     * @param brandName
     * @return
     */
    public Computer getComputer(String brandName)
    {
        if ("Dell".equals(brandName))
        {
            return new DellFactory().getComputer();
        }
        else if ("Lenovo".equals(brandName))
        {
            return new LenovoFactory().getComputer();
        }
        else if ("MacBook".equals(brandName))
        {
            return new MacBookFactory().getComputer();
        }
        else
        {
            System.out.println("未找到该品牌电脑！");
            return null;
        }
    }
    
}
